$(function() {
	//弹出模态框
	var editDom = $("#edit");
	var modalBox = $("#modalBox");
	editDom.click(function() {
		layer.open({
			title:'福利待遇',
			type: 1,
			area: ['500px'],
			btn:["确认","取消"],
			content: $('#modalBox'),
			yes:function(index, layero){
				if($('.welfare .right .lable')) {
					$('.welfare .right .lable').remove();
				}
			    var avtiveDom = $('.modal-box .modal-container .lables .active');
			    var lableArray = [];
			    for(var i = 0;i < avtiveDom.length;i++) {
			    	lableArray[i] = avtiveDom.eq(i).html();
			    	editDom.before('<span class="lable">'+ lableArray[i] +'</span>');
			    }
			    layer.close(index);
			},
		});
	})
	
	//模态框选择标签
	$(document).on('click', '.modal-box .modal-container .lables li', function() {
		$(this).toggleClass("active");
	});
	
	var customLable = $("#customLable");
	var ulDom = $(".modal-box .modal-container .lables");
	$("#addLable").click(function() {
		var customLableHtml = customLable.val();
		if(customLableHtml != ""){
			ulDom.append('<li>' + customLableHtml + '</li>');
			customLable.val('');
		}
	});
})
